package com.hancher.gamelife2.colockin;


import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.hancher.common.androidutil.AssetUtil;
import com.hancher.common.javautil.DateUtil;
import com.hancher.common.rv.BaseVBAdapter;
import com.hancher.gamelife2.databinding.ItemColockInListBinding;

import java.io.File;

public class ColockInListAdapter extends BaseVBAdapter<ItemColockInListBinding, ColockInPO> {

    private String bitmapPath;

    public ColockInListAdapter(String bitmapPath) {
        this.bitmapPath = bitmapPath;
    }

    @Override
    protected ItemColockInListBinding createViewBinding(LayoutInflater from, ViewGroup viewGroup) {
        return ItemColockInListBinding.inflate(from, viewGroup, false);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convertItem(ItemColockInListBinding binding, int position, ColockInPO item) {
        binding.itemTitle.setText(item.getDescription());
        binding.itemTime.setText(DateUtil.stamp2allStr(item.getUpdateTime()));

        Bitmap bitmap = AssetUtil.getImage(getContext(), "colockintype" + File.separator + bitmapPath);
        if (bitmap != null) {
            binding.itemImage.setImageBitmap(bitmap);
        }
    }

    public void setImage(String bitmapPath) {
        this.bitmapPath = bitmapPath;
    }
}
